<template>
  <div class=''>
    <!--  -->
    <Bootstrap v-bind:BootstrapTitle="BootstrapTitle"></Bootstrap>
    <el-card>
      <el-row>
        <el-col :span="6">
          <el-input placeholder="请输入内容" v-model="queryInfo.query" class="input-with-select">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!-- 表格 -->
      <el-table :data="OrdersList" border stripe>
        <el-table-column type="index">

        </el-table-column>
        <el-table-column label="订单编号" prop="order_number" width="600">

        </el-table-column>
        <el-table-column label="订单价格(元)" prop="order_price" width="80">

        </el-table-column>
        <el-table-column label="是否付款" prop="pay_status" width="80">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.pay_status ==='1'">已付款</el-tag>
            <el-tag type="danger" v-else>未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="是否发货" prop="is_send" width="80">

        </el-table-column>
        <el-table-column label="下单时间" prop="create_time" width="175">
          <template slot-scope="scope">{{scope.row.create_time | dateFormat}}</template>
        </el-table-column>
        <el-table-column label="操作" width="120">
          <template slot-scope="scope">
            <el-button type="primary" icon="el-icon-edit" size="mini" @click="xiugaiOrders(scope.row.order_id)">
            </el-button>
            <el-button size="mini" type="success" class="iconfont icon-icon1460188781620" @click="showProgreessBox">
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum" :page-sizes="[10, 15, 20, 25]" :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
      <!-- 对话框 -->
      <el-dialog title="修改地址" :visible.sync="xiugaidialogVisible" width="45%" @close="addDiallogClose">
        <el-form :model="addRessFrom" :rules="addRessRules" ref="addRessFromRef" label-width="100px"
          class="demo-ruleForm">
          <el-form-item label="省市区/县" prop="address1">
            <el-cascader :options="cityData" v-model="addRessFrom.address1"></el-cascader>
          </el-form-item>
          <el-form-item label="详细地址" prop="address2">
            <el-input v-model="addRessFrom.address2"></el-input>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button size="small" @click="xiugaidialogVisible = false">取 消</el-button>
          <el-button size="small" type="primary" @click="xiugaidialogVisible = false">确 定</el-button>
        </span>
      </el-dialog>
      <!-- 2 -->
      <el-dialog title="提示" :visible.sync="logisticsDialogVisible" width="30%">
        <el-timeline >
          <el-timeline-item v-for="(activity, index) in logisticsData" :key="index" :timestamp="activity.time">
            {{activity.context}}
          </el-timeline-item>
        </el-timeline>
        <span slot="footer" class="dialog-footer">
          <el-button @click="logisticsDialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="logisticsDialogVisible = false">确 定</el-button>
        </span>
      </el-dialog>
    </el-card>
  </div>
</template>
<script>
import Bootstrap from "../../component/component/Bootstrap";
import cityData from "./citydata.js";
export default {
  name: "",
  components: {
    Bootstrap,
  },
  data() {
    return {
      BootstrapTitle: {
        first: "订单管理",
        second: "/orders",
        third: "订单列表",
      },
      queryInfo: {
        query: "",
        pagenum: 1,
        pagesize: 10,
      },
      OrdersList: [],
      total: 0,
      xiugaidialogVisible: false,
      logisticsDialogVisible: false,
      addRessFrom: {
        address1: [],
        address2: "",
      },
      addRessRules: {
        address1: [
          { required: true, message: "请输入详细地址", trigger: "blur" },
        ],
        address2: [
          { required: true, message: "请输入详细地址", trigger: "blur" },
        ],
      },
      cityData,
      logisticsData: [
       
            {
              time: "2018-05-10 09:39:00",
              ftime: "2018-05-10 09:39:00",
              context: "已签收,感谢使用顺丰,期待再次为您服务",
              location: "",
            },
            {
              time: "2018-05-10 08:23:00",
              ftime: "2018-05-10 08:23:00",
              context:
                "[金华市]金华婺城区育新小区营业点派件员 顺丰速运 95338正在为您派件",
              location: "",
            },
            {
              time: "2018-05-10 07:32:00",
              ftime: "2018-05-10 07:32:00",
              context: "快件到达 [金华婺城区育新小区营业点]",
              location: "",
            },
            {
              time: "2018-05-10 02:03:00",
              ftime: "2018-05-10 02:03:00",
              context:
                "快件在[金华义乌集散中心]已装车,准备发往 [金华婺城区育新小区营业点]",
              location: "",
            },
            {
              time: "2018-05-09 23:05:00",
              ftime: "2018-05-09 23:05:00",
              context: "快件到达 [金华义乌集散中心]",
              location: "",
            },
            {
              time: "2018-05-09 21:21:00",
              ftime: "2018-05-09 21:21:00",
              context:
                "快件在[金华宝胜营业点]已装车,准备发往 [金华义乌集散中心]",
              location: "",
            },
            {
              time: "2018-05-09 13:07:00",
              ftime: "2018-05-09 13:07:00",
              context: "顺丰速运 已收取快件",
              location: "",
            },
            {
              time: "2018-05-09 12:25:03",
              ftime: "2018-05-09 12:25:03",
              context: "卖家发货",
              location: "",
            },
            {
              time: "2018-05-09 12:22:24",
              ftime: "2018-05-09 12:22:24",
              context: "您的订单将由HLA（金华婺城区区清河中街店）门店安排发货。",
              location: "",
            },
            {
              time: "2018-05-08 21:36:04",
              ftime: "2018-05-08 21:36:04",
              context: "商品已经下单",
              location: "",
            },
          ],
          meta: { status: 200, message: "获取物流信息成功！" },
      
    };
  },
  created() {
    this.getOrdersList();
  },
  methods: {
    async getOrdersList() {
      let res = await this.$http.get("orders", { params: this.queryInfo });
      if (res.data.meta.status !== 200) {
        return this.$message.error(res.data.meta.msg);
      } else {
        this.$message.success(res.data.meta.msg);
        this.OrdersList = res.data.data.goods;
        this.total = res.data.data.total;
      }
    },
    // 监听条数
    handleSizeChange(size) {
      //console.log(size, "size");
      this.queryInfo.pagesize = size;
      this.getOrdersList();
    },
    // 监听页数
    handleCurrentChange(page) {
      // console.log(page, "page");
      this.queryInfo.pagenum = page;
      this.getOrdersList();
    },
    xiugaiOrders() {
      this.xiugaidialogVisible = true;
    },
    addDiallogClose() {
      this.$refs.addRessFromRef.resetFields();
      console.log(123);
    },
    async showProgreessBox() {
      this.logisticsDialogVisible = true;
    },
  },
};
</script>
<style lang='less' scoped>
.icon-icon1460188781620 {
  font-size: 9px;
}
</style>